<!DOCTYPE html>
<html>
    <body>
        <button onclick="fun()">查看消息</button>

        <script>
            function fun(){
                var txt="";
            try{
                addlert("Welcom");
            }catch(err){
                txt = "本页有错误。\n\n";
                txt+="错误描述"+err.message+"\n\n";
                alert(txt);
            }
            }
            
        </script>
    </body>
</html>